home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / ConditionalMacros.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-04  |  9.8 KB  |  262 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ConditionalMacros.h
  3.  
  4.      Contains:    Compile time feature switches to achieve platform independent sources.
  5.  
  6.      Version:    Technology:    Universal Interface Files 2.1
  7.                  Package:    Universal Interfaces 2.1.4
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21. #define __CONDITIONALMACROS__
  22.  
  23. /*
  24.  
  25.     Set up UNIVERSAL_INTERFACES_VERSION
  26.     
  27.         0x214 => version 2.1.4
  28.         0x212 => version 2.1.2
  29.         0x210 => version 2.1
  30.         This conditional did not exist prior to version 2.1
  31. */
  32. #define UNIVERSAL_INTERFACES_VERSION 0x0214
  33.  
  34. /****************************************************************************************************
  35.     GENERATINGPOWERPC        - Compiler is generating PowerPC instructions
  36.     GENERATING68K            - Compiler is generating 68k family instructions
  37.  
  38.         Invariant:
  39.             GENERATINGPOWERPC != GENERATING68K
  40.  ****************************************************************************************************/
  41. #ifdef GENERATINGPOWERPC
  42.     #ifndef GENERATING68K
  43. #define GENERATING68K !GENERATINGPOWERPC
  44.     #endif
  45. #endif
  46. #ifdef GENERATING68K
  47.     #ifndef GENERATINGPOWERPC
  48. #define GENERATINGPOWERPC !GENERATING68K
  49.     #endif
  50. #endif
  51. #ifndef GENERATINGPOWERPC
  52.     #if defined(powerc) || defined(__powerc)
  53. #define GENERATINGPOWERPC 1
  54.     #else
  55. #define GENERATINGPOWERPC 0
  56.     #endif
  57. #endif
  58. #ifndef GENERATING68K
  59.     #if GENERATINGPOWERPC
  60. #define GENERATING68K 0
  61.     #else
  62. #define GENERATING68K 1
  63.     #endif
  64. #endif
  65.  
  66. /****************************************************************************************************
  67.     GENERATING68881            - Compiler is generating mc68881 floating point instructions
  68.     
  69.         Invariant:
  70.             GENERATING68881 => GENERATING68K
  71.  ****************************************************************************************************/
  72. #if GENERATING68K
  73.     #if defined(applec) || defined(__SC__)
  74.         #ifdef mc68881
  75. #define GENERATING68881 1
  76.         #endif
  77.     #else
  78.         #ifdef __MWERKS__
  79.             #if __MC68881__
  80. #define GENERATING68881 1
  81.             #endif
  82.         #endif
  83.     #endif
  84. #endif
  85. #ifndef GENERATING68881
  86. #define GENERATING68881 0
  87. #endif
  88.  
  89. /****************************************************************************************************
  90.     GENERATINGCFM            - Code being generated assumes CFM calling conventions
  91.     CFMSYSTEMCALLS            - No A-traps.  Systems calls are made using CFM and UPP's
  92.  
  93.         Invariants:
  94.             GENERATINGPOWERPC => GENERATINGCFM
  95.             GENERATINGPOWERPC => CFMSYSTEMCALLS
  96.             CFMSYSTEMCALLS => GENERATINGCFM
  97. ****************************************************************************************************/
  98. #if GENERATINGPOWERPC || defined(__CFM68K__)
  99. #define GENERATINGCFM 1
  100. #define CFMSYSTEMCALLS 1
  101. #else
  102. #define GENERATINGCFM 0
  103. #define CFMSYSTEMCALLS 0
  104. #endif
  105. /*
  106.  
  107.     Set up SystemSevenFiveOrLater, SystemSevenOrLater, and SystemSixOrLater
  108.  
  109. */
  110. #ifndef SystemSevenFiveOrLater
  111. #define SystemSevenFiveOrLater 0
  112. #endif
  113. #ifndef SystemSevenOrLater
  114.     #if GENERATINGCFM
  115. #define SystemSevenOrLater 1
  116.     #else
  117. #define SystemSevenOrLater SystemSevenFiveOrLater
  118.     #endif
  119. #endif
  120. #ifndef SystemSixOrLater
  121. #define SystemSixOrLater SystemSevenOrLater
  122. #endif
  123.  
  124. /****************************************************************************************************
  125.  
  126.     OLDROUTINENAMES            - "Old" names for Macintosh system calls are allowed in source code.
  127.                               (e.g. DisposPtr instead of DisposePtr). The names of system routine
  128.                               are now more sensitive to change because CFM binds by name.  In the 
  129.                               past, system routine names were compiled out to just an A-Trap.  
  130.                               Macros have been added that each map an old name to its new name.  
  131.                               This allows old routine names to be used in existing source files,
  132.                               but the macros only work if OLDROUTINENAMES is true.  This support
  133.                               will be removed in the near future.  Thus, all source code should 
  134.                               be changed to use the new names! You can set OLDROUTINENAMES to false
  135.                               to see if your code has any old names left in it.
  136.     
  137.     OLDROUTINELOCATIONS     - "Old" location of Macintosh system calls are used.  For example, c2pstr 
  138.                               has been moved from Strings to TextUtils.  It is conditionalized in
  139.                               Strings with OLDROUTINELOCATIONS and in TextUtils with !OLDROUTINELOCATIONS.
  140.                               This allows developers to upgrade to newer interface files without suddenly
  141.                               all their code not compiling becuase of "incorrect" includes.  But, it
  142.                               allows the slow migration of system calls to more understandable file
  143.                               locations.  OLDROUTINELOCATIONS currently defaults to true, but eventually
  144.                               will default to false.
  145.  
  146. ****************************************************************************************************/
  147. #ifndef OLDROUTINENAMES
  148. #define OLDROUTINENAMES 1
  149. #endif
  150. #ifndef OLDROUTINELOCATIONS
  151. #define OLDROUTINELOCATIONS 1
  152. #endif
  153.  
  154. /****************************************************************************************************
  155.  
  156.     C specific conditionals
  157.  
  158.     CGLUESUPPORTED            - Interface library will support "C glue" functions (function names
  159.                               are: all lowercase, use C strings instead of pascal strings, use 
  160.                               Point* instead of Point).
  161.  
  162.     PRAGMA_ALIGN_SUPPORTED    - Compiler supports "#pragma align=..." directives. The only compilers that
  163.                               can get by without supporting the pragma are old classic 68K compilers
  164.                               that will only be used to compile older structs that have 68K alignment
  165.                               anyways.  
  166.     
  167.     PRAGMA_IMPORT_SUPPORTED    - Compiler supports "#pragma import on/off" directives.  These directives
  168.                               were introduced with the SC compiler which supports CFM 68K.  The directive
  169.                               is used to tell the compiler which functions will be called through a 
  170.                               transition vector (instead of a simple PC-relative offset).  This allows 
  171.                               the compiler to generate better code.  Since System Software functions are
  172.                               implemented as shared libraries and called through transition vectors,
  173.                               all System Software functions are declared with "#pragma import on".
  174.                               
  175.         Invariants:
  176.             PRAGMA_IMPORT_SUPPORTED => CFMSYSTEMCALLS
  177.             GENERATINGPOWERPC => PRAGMA_ALIGN_SUPPORTED
  178.             
  179. ****************************************************************************************************/
  180. #ifndef CGLUESUPPORTED
  181.     #ifdef THINK_C
  182. #define CGLUESUPPORTED 0
  183.     #else
  184. #define CGLUESUPPORTED 1
  185.     #endif
  186. #endif
  187.  
  188. /* All PowerPC compilers support pragma align */
  189. /* For 68K, only Metrowerks and SC 8.0 support pragma align */
  190. #ifndef PRAGMA_ALIGN_SUPPORTED
  191.     #if GENERATINGPOWERPC || defined(__MWERKS__) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  192.         #define  PRAGMA_ALIGN_SUPPORTED 1
  193.     #else
  194.         #define  PRAGMA_ALIGN_SUPPORTED 0
  195.     #endif
  196. #endif
  197.  
  198. /* pragma import on/off is supported by: Metowerks CW7 and later, SC 8.0 and later, MrC 2.0 and later */
  199. /* pragma import reset is supported by: Metrowerks and MrC 2.0.2 and later, but not yet by SC */
  200. #ifndef PRAGMA_IMPORT_SUPPORTED
  201.     #if ( defined(__MWERKS__) && (__MWERKS__ >= 0x0700) ) || ( defined(__SC__) && (__SC__ >= 0x0800) )
  202.         #define  PRAGMA_IMPORT_SUPPORTED 1
  203.     #elif defined(__MRC__) && ((__MRC__ & 0x0F00) == 0x0200) /* MrC 1.0 used 0x0704 and 0x0800 */
  204.         #define  PRAGMA_IMPORT_SUPPORTED 1
  205.     #else
  206.         #define  PRAGMA_IMPORT_SUPPORTED 0
  207.     #endif
  208. #endif
  209.  
  210.  
  211. /****************************************************************************************************
  212.  
  213.     Set up old "USES..." conditionals to support 1.0 universal interface files
  214.  
  215.     The USESxxx names are old, but cannot be removed yet because source code that
  216.     uses them might still compile, but do the wrong thing. 
  217.     
  218. ****************************************************************************************************/
  219. #ifndef USES68KINLINES
  220. #define USES68KINLINES GENERATING68K
  221. #endif
  222. #define USESCODEFRAGMENTS GENERATINGCFM
  223. #define USESROUTINEDESCRIPTORS GENERATINGCFM
  224.  
  225. /****************************************************************************************************
  226.  
  227.     The following macros isolate the use of inlines from the routine prototypes.
  228.     A routine prototype will always be followed by on of these inline macros with
  229.     a list of the opcodes to be inlined.  On the 68K side, the appropriate inline
  230.     code will be generated.  On platforms that use code fragments, the macros are
  231.     essentially NOPs.
  232.     
  233. ****************************************************************************************************/
  234. #if CFMSYSTEMCALLS
  235. #define ONEWORDINLINE(trapNum)
  236. #define TWOWORDINLINE(w1,w2)
  237. #define THREEWORDINLINE(w1,w2,w3)
  238. #define FOURWORDINLINE(w1,w2,w3,w4)
  239. #define FIVEWORDINLINE(w1,w2,w3,w4,w5)
  240. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)
  241. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)
  242. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)
  243. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)
  244. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)
  245. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)
  246. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)
  247. #else
  248. #define ONEWORDINLINE(trapNum) = trapNum
  249. #define TWOWORDINLINE(w1,w2) = {w1,w2}
  250. #define THREEWORDINLINE(w1,w2,w3) = {w1,w2,w3}
  251. #define FOURWORDINLINE(w1,w2,w3,w4)  = {w1,w2,w3,w4}
  252. #define FIVEWORDINLINE(w1,w2,w3,w4,w5) = {w1,w2,w3,w4,w5}
  253. #define SIXWORDINLINE(w1,w2,w3,w4,w5,w6)     = {w1,w2,w3,w4,w5,w6}
  254. #define SEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7)      = {w1,w2,w3,w4,w5,w6,w7}
  255. #define EIGHTWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8)      = {w1,w2,w3,w4,w5,w6,w7,w8}
  256. #define NINEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9}
  257. #define TENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10)  = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10}
  258. #define ELEVENWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11}
  259. #define TWELVEWORDINLINE(w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12)      = {w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12}
  260. #endif
  261. #endif /* __CONDITIONALMACROS__ */
  262.